<?php
//Installer for ORS
ini_set("display_errors", 1); //activeer de display_error 

$current_step = $_GET['step'];

echo "<html>";
echo "<header>";

echo "</header>";

echo "<body>";

switch ($current_step) {
    case 2:
        echo "<h1>Step 2: Site settings</h1>";
        
        echo "<p>This step will gather all settings regarding the oRs installation.</p>";
            
        echo "<p>Please enter the following settings: </p>";
        
        echo "<form action=\"./installer.php?step=3\" method=\"post\">";

				echo "<fieldset>";
				echo "<legend>World of Warcraft data</legend>";
				
				echo "<table>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Guild name</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='text' name='guild' />";
						echo "</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td>";
							echo "<label for='database'>Server name</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='text' name='server' />";
						echo "</td>";
					echo "</tr>";
				echo "</table>";
				
				echo "</fieldset>";
				
				echo "<fieldset>";
				echo "<legend>System settings</legend>";
				
				echo "<table>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Do you wish to use the Raid signup system?</label>";
						echo "</td>";
						echo "<td>";
							echo "<select name='raidsystem' />";
								echo "<option value='1'>Yes</option>";
								echo "<option value='0'>No</option>";
							echo "</select>";
						echo "</td>";
					echo "</tr>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Do you wish to use the Raid points system?</label>";
						echo "</td>";
						echo "<td>";
							echo "<select name='pointsystem' />";
								echo "<option value='1'>Yes</option>";
								echo "<option value='0'>No</option>";
							echo "</select>";
						echo "</td>";
					echo "</tr>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Do you wish to use the Private Messaging system?</label>";
						echo "</td>";
						echo "<td>";
							echo "<select name='pmsystem' />";
								echo "<option value='1'>Yes</option>";
								echo "<option value='0'>No</option>";
							echo "</select>";
						echo "</td>";
					echo "</tr>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Do you wish to use the Armory integration?</label>";
						echo "</td>";
						echo "<td>";
							echo "<select name='armorysystem' />";
								echo "<option  value='1'>Yes</option>";
								echo "<option selected value='0'>No</option>";
							echo "</select><span>(Requires Cron access)</span>";
						echo "</td>";
					echo "</tr>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Do you wish to enable wowhead item integration?</label>";
						echo "</td>";
						echo "<td>";
							echo "<select name='itemsystem' />";
								echo "<option value='1'>Yes</option>";
								echo "<option value='0'>No</option>";
							echo "</select>";
						echo "</td>";
					echo "</tr>";
				echo "</table>";
				
				echo "</fieldset>";
				
				echo "<fieldset>";
				echo "<legend>Administrator data</legend>";
				
				echo "<table>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Website admin username</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='text' name='adminuser' />";
						echo "</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td>";
							echo "<label for='database'>Website admin password</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='password' name='adminpassword' />";
						echo "</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td>";
							echo "<label for='database'>Repeat</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='password' name='repeatpassword' />";
						echo "</td>";
					echo "</tr>";
				echo "</table>";
				
				echo "</fieldset>";
				
				echo "<input type='submit' value='Continue' />";
				
				echo "</form>";

        break;
    case 3:
   
	    $settings['guild'] = $_POST['guild'];
	    $settings['server'] =  $_POST['server'];
	    $settings['raidsystem'] = $_POST['raidsystem'];
	    $settings['pointsystem'] = $_POST['pointsystem'];
	    $settings['pmsystem'] = $_POST['pmsystem'];
	    $settings['armorysystem'] = $_POST['armorysystem'];
	    $settings['itemsystem'] = $_POST['itemsystem'];
	    $settings['adminuser'] = $_POST['adminuser'];
	    $settings['adminpassword'] = $_POST['adminpassword'];
	    $settings['repeatpassword'] = $_POST['repeatpassword'];
    
   
        echo "<h1>Step 3: Database settings</h1>";
        
        echo "<p>In order to be able to use the system you need a MySQL database. This step gathers the information to create the tables and default data.</p>";
        
				echo "<p>Please enter the following database settings: </p>";
				
				echo "<form action=\"./installer.php?step=4\" method=\"post\">";

				echo "<table>";
	  			echo "<tr>";
		  			echo "<td>";
							echo "<label for='server'>Server name</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='text' name='server' />";
						echo "</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td>";
							echo "<label for='database'>Database</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='text' name='database' />";
						echo "</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td>";
							echo "<label for='user'>User</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='text' name='user' />";
						echo "</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td>";
							echo "<label for='password'>Password</label>";
						echo "</td>";
						echo "<td>";
							echo "<input type='password' name='password' />";
						echo "</td>";
					echo "</tr>";
				echo "</table>";
				
				$post_settings = base64_encode(serialize($settings));
				
				echo "<input type='hidden' value='$post_settings' />";
				
				echo "<input type='submit' value='Continue' />";
				
				echo "</form>";
        break;
    case 4:
        
		
        break;
    default:
       echo "<h1>Welcome to the oRs installer.</h1><p>This installer will guide you through the installation so all neccesary settings and dependacies will be configured. Just follow the step and enter the information and you should be all set to go!</p>";
	   
	   echo "<p><a href=\"./installer.php?step=2\">Continue</a></p>";
	   break;
}

echo "</body>";
echo "</html>";
?>